@use 'sass:map';
@use './light';
@use './dark';
@use '_variables' as v;

@mixin apply-theme($name, $values, $default-values) {
	@each $variable, $default-value in $default-values {
		$final-value: $default-value;
		@if map.has-key($values, $variable) {
			$final-value: map.get($values, $variable);
		}

		@include v.set($variable, $final-value);
	}
}

:root,/* default theme */
:root.light {
	@include apply-theme('light', light.$values, light.$values);
}

:root.dark {
	@include apply-theme('dark', dark.$values, light.$values);
}
